package com.tengits.react.amap3d.maps;

import androidx.annotation.NonNull;

import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewGroupManager;
import com.facebook.react.uimanager.annotations.ReactProp;
import com.tengits.react.amap3d.AMapUtils;

import java.util.Map;

public class AMapPolylineManager extends ViewGroupManager<AMapPolyline> {
  @NonNull
  @Override
  public String getName() {
    return "AMapPolyline";
  }

  @NonNull
  @Override
  protected AMapPolyline createViewInstance(@NonNull ThemedReactContext reactContext) {
    return new AMapPolyline(reactContext);
  }

  @Override
  public Map getExportedCustomDirectEventTypeConstants() {
    return MapBuilder.of("onPress", MapBuilder.of("registrationName","onPress"));
  }

  @ReactProp(name = "coordinates")
  public void setCoordinate(AMapPolyline polyline, ReadableArray coordinates) {
    polyline.setCoordinates(coordinates);
  }

  @ReactProp(name = "colors")
  public void setColors(AMapPolyline polyline, ReadableArray colors) {
    polyline.setColors(colors);
  }

  @ReactProp(name = "color", customType = "Color")
  public void setColor(AMapPolyline polyline, Integer color) {
    polyline.setColor(color);
  }

  @ReactProp(name = "width")
  public void setWidth(AMapPolyline polyline, Float width) {
    polyline.setWidth((float) AMapUtils.toPx(width));
  }

  @ReactProp(name = "zIndex")
  public void setZIndex(AMapPolyline polyline, Float zIndex) {
    polyline.setZIndex(zIndex);
  }

  @ReactProp(name = "geodesic")
  public void setGeodesic(AMapPolyline polyline, Boolean geodesic) {
    polyline.setGeodesic(geodesic);
  }

  @ReactProp(name = "dashed")
  public void setDashed(AMapPolyline polyline, Boolean dashed) {
    polyline.setDashed(dashed);
  }

  @ReactProp(name = "gradient")
  public void setGradient(AMapPolyline polyline, Boolean gradient) {
    polyline.setGradient(gradient);
  }
}
